<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>修改密码</title>
<link href="__PUBLIC__/css/bootstrap.min.css" rel="stylesheet">
<script src="__PUBLIC__/js/jquery.min.js"></script>
<style type="text/css">
	.changepwd {
		width: 400px;
		padding-top: 10%;
	}
	@media(max-width: 430px){
		.changepwd {
			width: 300px;
		}
	}
</style>
</head>
<body>
<h3>找回密码</h3>
<div style="width: 150px;height: 2px;background-color: lightskyblue;"></div>
<a href="{:U('index/index')}" class="btn btn-default">返回首页</a>
<div class="changepwd center-block">
	<form action="" method="post" name="main_login">
		<div class="form-group">
			<label>手机验证</label>
			<div class="input-group" style="width: 100%;">
				<input onclick="countTime($(this));tphone()" type="button" class="btn" value="获取验证码" style="width: 30%;">
				<input class="form-control" type="text" placeholder="请输入手机号" name="phone" style="width: 70%;" maxlength="20" id="phone">
			</div>
		</div>
		<div class="form-group">
			<label>验证码</label>
			<div class="input-group">
				<div class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></div>
				<input class="form-control" type="text" placeholder="请输入验证码" name="checkcode" maxlength="6">
			</div>
		</div>
		<div class="form-group">
			<label>修改密码</label>
			<div class="input-group">
				<span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
				<input class="form-control" type="password" placeholder="请输入密码" name="changepassword" maxlength="20">
			</div>
		</div>
		<div style="width: 70%;overflow: hidden;" class="center-block">
			<input type="submit" class="btn btn-info center-block" value="提交">
		</div>
	</form>
</div>
<script type="text/javascript">
	var t = 59;
	function countTime(obj){
			obj.attr("disabled","disabled");
			var count = setInterval(function(){
				obj.attr("value",t+"秒");
				t--;
				if (t<0) {
					t=60;
					clearInterval(count);
					obj.removeAttr("disabled");
					obj.attr("value","获取验证码");
				}
			},1000);
		}
	function tphone(){
			var xmlhttp;
			var str=document.getElementById("phone").value;
			if(str.length==0){
				document.getElementById("phoneN").innerHTML="";
				return;
			}
			if(window.XMLHttpRequest){
				xmlhttp=new XMLHttpRequest();
			}else{
				xmlhttp=new ActiveXobject("Microsoft.XMLHTTP");
			}
			xmlhttp.onreadystatechange=function(){
			    if (xmlhttp.readyState==4 && xmlhttp.status==200){
			      document.getElementById("phoneN").innerHTML=xmlhttp.responseText;
			    }
			}
			  xmlhttp.open("POST","__URL__/register_infer/str/"+str,true);
			  xmlhttp.send();
		}
		$("form[name=main_login]").submit(function(){
			$.ajax({
				type : "POST",
				url : "__SELF__",
				data : $(this).serialize(),
				dataType : "json",
				success : function(data){
					if(data.status == 1){
						alert(data.info);
						location.href = data.url;
					}else{
						alert(data.info);
					}
				}
			});
			return false;
		});
</script>
</body>
</html>